﻿/*
* 
* Adds an speech input field to the textarea for comments
* Version 1.0.0
* 
* A part of AT Tools.
* 
* Copyright (c) 2011 Peter Sandberg Brun
* Copyright (c) 2011 Mads Sandberg Brun
*
* Licensed under the MS-PL license:
* http://attools.codeplex.com/license
*
*/


if (typeof (document.createElement('input').onwebkitspeechchange) != 'undefined') {
    var commentarea = document.getElementById('comment-text');

    if (commentarea != "undefined") {
        var input = document.createElement('input');
        input.setAttribute('x-webkit-speech', 'x-webkit-speech');
        input.setAttribute('speech', 'speech');
        input.style.color = 'transparent';
        input.style.backgroundColor = 'transparent';
        input.style.border = '0px';
        input.style.width = '20px';
        input.setAttribute('onwebkitspeechchange', 'updateCommentArea(this.value);');
        commentarea.parentNode.appendChild(input);
    }
}
    
function updateCommentArea(text) {
    if (commentarea.value == "") {
        commentarea.value = text;
    } else {
        commentarea.value = commentarea.value + ' ' + text;
    }

}
